﻿
//-------------------------------------------------------------------------------
// <copyright file="Programmatically.aspx.cs" company="GrannetDotNet Software">
//     Copyright © 2009 GrannetDotNet Software. All rights reserved.
// </copyright>
// <author>Grant Harmeyer</author>
//-------------------------------------------------------------------------------

using System.Web.UI;
using System.Web.UI.WebControls;
using GrannetDotNet.Web.UI.WebControls;

/// <summary>
/// Web Form used to demonstrate how an SwfObject control can be added to a page programmatically
/// </summary>
public partial class Programmatically 
    : Page
{
    #region [ Methods ]

    /// <summary>
    /// Creates instances of child controls of the Page
    /// </summary>
    protected override void CreateChildControls()
    {
        SwfObject                 swfObj1        = null;
        SwfObjectAlternateContent swfObjContent1 = null;

        /* Invoke Base */
        base.CreateChildControls();

        /* Create SwfObject control */
        swfObj1                          = new SwfObject();
        swfObj1.ID                       = "swfObj1";
        swfObj1.AllowScriptAccess        = SwfScriptAccess.Always;
        swfObj1.BaseUrl                  = "~/App_Support/Flash/";
        swfObj1.ClientCallback           = "echoLoadStatus";
        swfObj1.MovieUrl                 = "~/App_Support/Flash/player.swf";
        swfObj1.Height                   = Unit.Parse("200px");
        swfObj1.Width                    = Unit.Parse("328px");        
        swfObj1.UseDynamicPublishing     = false;
        swfObj1.UseExpressInstallation   = true;

        /* Add FlashVars */
        swfObj1.FlashVars.Add(new FlashVar("file", "video.flv"));
        swfObj1.FlashVars.Add(new FlashVar { Name = "image", Value = "preview.jpg" });

        /* Create Alternate Content Template */
        swfObjContent1                   = new SwfObjectAlternateContent();
        swfObjContent1.Controls.Add(new LiteralControl("<p><a href=\"http://get.adobe.com/flashplayer\">Get Flash</a> to see this player.</p>"));
        swfObj1.AlternateContentTemplate = swfObjContent1;

        /* Add the SwfObject to the PlaceHolder */
        this.plchGdnSwfObject.Controls.Add(swfObj1);
    }

    #endregion
}